package com.sjgtw.cloud.web.floodPlan.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.sjgtw.cloud.common.core.web.controller.BaseController;
import com.sjgtw.cloud.common.core.web.domain.AjaxResult;
import com.sjgtw.cloud.common.core.web.page.TableDataInfo;
import com.sjgtw.cloud.web.floodPlan.domain.FloodPlan;
import com.sjgtw.cloud.web.floodPlan.service.IFloodPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 水害处置方案Controller
 * 
 * @author ruoyi
 * @date 2024-03-16
 */
@RestController
@Api(tags = "1.11、水害类型管理")
@RequestMapping("/floodPlan")
public class FloodPlanController extends BaseController
{
    @Autowired
    private IFloodPlanService floodPlanService;

    /**
     * 查询水害处置方案列表
     */

    @GetMapping("/list")
    @ApiOperation("列表")
    public TableDataInfo list(FloodPlan floodPlan)
    {
        startPage();
        List<Map<String,Object>> list = floodPlanService.selectFloodPlanList(floodPlan);
        return getDataTable(list);
    }

    /**
     * 导出水害处置方案列表
     */

  /*  @PostMapping("/export")
    public void export(HttpServletResponse response, FloodPlan floodPlan)
    {
        List<FloodPlan> list = floodPlanService.selectFloodPlanList(floodPlan);
        ExcelUtil<FloodPlan> util = new ExcelUtil<FloodPlan>(FloodPlan.class);
        util.exportExcel(response, list, "水害处置方案数据");
    }*/

    /**
     * 获取水害处置方案详细信息
     */
    @ApiOperation("获取详细信息")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(floodPlanService.selectFloodPlanById(id));
    }

    /**
     * 新增水害处置方案
     */

    @PostMapping("/add")
    @ApiOperation("新增")
    public AjaxResult add(@RequestBody FloodPlan floodPlan)
    {
        return toAjax(floodPlanService.insertFloodPlan(floodPlan));
    }

    /**
     * 修改水害处置方案
     */

    @PutMapping("/edit")
    @ApiOperation("编辑")
    public AjaxResult edit(@RequestBody FloodPlan floodPlan)
    {
        return toAjax(floodPlanService.updateFloodPlan(floodPlan));
    }

    /**
     * 删除水害处置方案
     */
    @ApiOperation("删除")
	@DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(floodPlanService.deleteFloodPlanById(id));
    }
}
